package com.example.arithmeticleetcode.leetcode;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @program: arithmetic-leetcode
 * @description: 1456. 定长子串中元音的最大数目
 * @author: FangZhen
 * @create: 2020-05-27 19:13
 **/
public class Demo24 {

    public static void main(String[] args) {
        Integer status = 0;
        if (status == 0) {
            System.out.println("status = " + status);
        }

        List<String> list = new ArrayList<>();
        list.add("1");
        List<String> collect = list.stream().map(s -> s).collect(Collectors.toList());
        System.out.println("list ---------------" + list);

        String aeiou = "aeiou";
        System.out.println(aeiou.indexOf('o'));
        System.out.println(aeiou.indexOf('e'));
        System.out.println(aeiou.indexOf('w'));
        System.out.println(maxVowels("abciiidef", 3));
        System.out.println(maxVowels("aeiou", 2));
        System.out.println(maxVowels("leetcode", 3));
        System.out.println(maxVowels("rhythms", 4));
        System.out.println(maxVowels("tryhard", 4));
        System.out.println(maxVowels("weallloveyou", 7)); //4
        System.out.println(maxVowels("aeiou", 2)); //2
    }

    public static int maxVowels(String s, int k) {
        String aeiou = "aeiou";
        int count = 0;
        for (int i = 0, len = s.length() - k; i <= len; i++) {
            int temLen = 0;
            String str = s.substring(i, (i + k));
            for (int j = 0, jLen = str.length(); j < jLen; j++) {
                if (aeiou.indexOf(str.charAt(j)) > -1) {
                    temLen++;
                }
            }
            if (count < temLen) {
                count = temLen;
            }
            if (count == k) {
                return count;
            }
        }
        return count;
    }
}
